package com.aizuda.boot.modules.file.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 文件转换缓存表
 * 
 * @author yangshen
 * @date 2025-08-04
 */
@Schema(description = "文件转换缓存表")
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "file_conversion_cache")
public class FileConversionCache implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "主键ID")
    private Long id;

    /**
     * 源文件ID
     */
    @TableField(value = "source_file_id")
    @Schema(description = "源文件ID")
    private String sourceFileId;

    /**
     * 源文件Key
     */
    @TableField(value = "source_file_key")
    @Schema(description = "源文件Key")
    private String sourceFileKey;

    /**
     * 源文件MD5值，用于检测文件是否变更
     */
    @TableField(value = "source_file_md5")
    @Schema(description = "源文件MD5值")
    private String sourceFileMd5;

    /**
     * 转换后文件ID
     */
    @TableField(value = "target_file_id")
    @Schema(description = "转换后文件ID")
    private String targetFileId;

    /**
     * 转换后文件Key
     */
    @TableField(value = "target_file_key")
    @Schema(description = "转换后文件Key")
    private String targetFileKey;

    /**
     * 转换类型：WORD_TO_PDF, PDF_TO_WORD等
     */
    @TableField(value = "conversion_type")
    @Schema(description = "转换类型")
    private String conversionType;

    /**
     * 转换后文件大小
     */
    @TableField(value = "file_size")
    @Schema(description = "转换后文件大小")
    private Long fileSize;

    /**
     * 转换时间
     */
    @TableField(value = "created_time")
    @Schema(description = "转换时间")
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @TableField(value = "updated_time")
    @Schema(description = "更新时间")
    private LocalDateTime updatedTime;

    /**
     * 转换类型枚举
     */
    public enum ConversionType {
        WORD_TO_PDF("WORD_TO_PDF", "Word转PDF"),
        PDF_TO_WORD("PDF_TO_WORD", "PDF转Word");

        private final String code;
        private final String description;

        ConversionType(String code, String description) {
            this.code = code;
            this.description = description;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }
}